package com.wandian.util
{
	import flash.display.DisplayObject;

	/**
	 * 图片放大缩小
	 * @author long
	 */
	public class ZoomUtil
	{
		public function ZoomUtil()
		{
		}

		public static function imageZoomWH(mc:DisplayObject, maxWidth:Number, maxHeight:Number):void
		{
			var isZoom:Boolean;
			var srcWidth:Number;
			var srcHeight:Number;
			var newWidth:Number;
			var newHeight:Number;
			var conductimg:*=function():void
			{
				if (isZoom)
				{
					if (srcWidth / srcHeight >= maxWidth / maxHeight)
					{
						if (srcWidth > maxWidth)
						{
							newWidth=maxWidth;
							newHeight=srcHeight * maxWidth / srcWidth;
						}
						else
						{
							newWidth=srcWidth;
							newHeight=srcHeight;
						}
					}
					else if (srcHeight > maxHeight)
					{
						newHeight=maxHeight;
						newWidth=srcWidth * maxHeight / srcHeight;
					}
					else
					{
						newWidth=srcWidth;
						newHeight=srcHeight;
					}
				}
				else
				{
					newWidth=0;
					newHeight=0;
				}
				return;
			} 
			;
			srcWidth=mc.width;
			srcHeight=mc.height;
			maxWidth=maxWidth;
			maxHeight=maxHeight;
			if (srcWidth > 0)
			{
			}
			if (srcWidth > 0)
			{
				isZoom;
			}
			else
			{
				isZoom;
			}
			conductimg();
			mc.width=newWidth;
			mc.height=newHeight;
			return;
		} 

	}
}
